package com.bolang.onlycode.demo.expressway;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
// 高速公路
public class ExpressWay {
    //公路名称
    private Integer id;
    //公路名称
    private String wayName;
    //公路起点里程
    private Integer start;
    //公路终点里程
    private Integer end;
    //公路里程
    private Integer length;

    public void printLength() {
        System.out.println(this.getWayName() + ", 共" + this.length + "公里");
    }

    public void printStation(List<PriceStation> list) {
        StringBuilder builder = new StringBuilder(this.wayName + "收费站有： ");
        for (PriceStation priceStation : list) {
            if (this.getId().equals(priceStation.getWayId())) {
                builder.append(priceStation.getStationName()).append("、");
            }
        }
        System.out.println(builder.deleteCharAt(builder.length() - 1));
    }

    public ExpressWay(Integer id, String wayName, Integer start, Integer end) {
        this.id = id;
        this.wayName = wayName;
        this.start = start;
        this.end = end;
        length = end - start;
    }


}
